﻿@model PagedList.IPagedList<Models.DataModel.Country>
@using PagedList.Mvc;
@{
    ViewBag.Title = "Country";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>List Country</h2>
@using (Html.BeginForm("Index", "Country", FormMethod.Get))
{
    <div class="form-inline" >
        <div class="form-group">
            <input type="text" class="form-control" id="searchtext" name="searchtext" placeholder="Please input value" value="@ViewBag.SearchText">
        </div>
        <button type="submit" class="btn btn-default">Search</button>
        <button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("Create", "Country")'">Add New Country</button>
    </div>
}
@using (Html.BeginForm("DeleteSelected", "Country", FormMethod.Post))
{
    <br />
    <div class="table-responsive">
        <table class="table table-bordered table-condensed">
            <thead>
                <tr>
                    <td class="text-normal" style="width:60px;">
                        <input id="ChkCheckFull" name="delall" type="checkbox" value="" />
                        <button type="submit" class="glyphicon glyphicon-trash btn-sm" value="" onclick="return confirm('Are you sure you want to delete this item selected ?');" style="color:red; border:none; background:none"></button>
                    </td>
                    <td class="text-normal">
                        @Html.Label("Code")
                    </td>
                    <td class="text-normal">
                        @Html.Label("Name")
                    </td>
                    <td>@Html.Label("Option")</td>
                </tr>
            </thead>
            <tbody>
                @{
    int i = 0;
    foreach (var item in Model)
    {
        ++i;
        var style = i % 2 == 0 ? "even" : "odd";
        <tr class="@style">
            <td>
                <input type="checkbox" class="checkCust" name="countryItemDelete" id="countryItemDelete" value="@item.CountryId" />
            </td>
            <td>
                <a href="@Url.Action("Edit", "Country", new { id = item.CountryId })">@item.Code</a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.CountryId }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.CountryId }, new { onclick = "return confirm('Are you sure you want to delete this " + @item.Name + "?');" })
            </td>
        </tr>
    }
                }
            </tbody>
        </table>

    </div>
}
<br />
 Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
              new { page, searchtext = ViewBag.SearchText }))
<script>
    $("#ChkCheckFull").click(function () {
        if ($("#ChkCheckFull").is(':checked') == true) {
            $(".checkCust").prop('checked', true);
        }
        else {
            $(".checkCust").prop('checked', false);
        }

    });
</script>